﻿using System;
using System.Data;
using System.Collections.Generic;
using DataLib.Common;
using DataLib.Model;
namespace DataLib.BLL
{


    /// <summary>
    /// 生产相关操作类
    /// </summary>
    public partial class Productions
    {
        private readonly DataLib.DAL.Productions dal = new DataLib.DAL.Productions();

        public Productions()
        { }

               /// <summary>
        /// 领料提交
        /// </summary>
        /// <param name="insid"></param>
        /// <param name="outid"></param>
        /// <param name="month"></param>
        /// <returns></returns>
        public int LingliaoSubmit(int insid, int outid, string month)
        {
            return dal.LingliaoSubmit(insid, outid, month);
        }

               /// <summary>
        /// 录入提交 更改生产出库单状态
        /// </summary>
        /// <param name="outid"></param>
        /// <returns></returns>
        public int LuRuSubmit(int outid)
        {
            return dal.LuRuSubmit(outid);
        }

          /// <summary>
        /// 生产提交
        /// <param name="outid">出库单id</param>
        /// </summary>
        public bool publicSubmit(int outid)
        {
            return dal.publicSubmit(outid);
        }

        
        /// <summary>
        /// 获取某段时间内的生产库存
        /// </summary>
        /// <param name="startdate">开始日期</param>
        /// <param name="enddate">结束日期</param>
        /// <param name="gcode">物品编码</param>
        /// <param name="strbelong">归属地</param>
        /// <param name="strdis">物理地</param>
        /// <param name="stroageno">仓库编号</param>
        /// <returns></returns>
        public DataTable GetStorageTotal(DateTime startdate, DateTime enddate, string strbelong, string strdis, string gcode, string stroageno)
        {
            return dal.GetStorageTotal(startdate, enddate, strbelong, strdis, gcode, stroageno);
        }

              /// <summary>
        /// 获取某段时间内的生产库存明细
        /// </summary>
        /// <param name="startdate">开始日期</param>
        /// <param name="enddate">结束日期</param>
        /// <param name="strbelong">仓库所属城市</param>
        /// <param name="strdis">仓库地理位置</param>
        /// <param name="gcode">物品编码</param>
        /// <param name="stroageno">库位号</param>
        /// <param name="flag">明细类型</param>
        /// <returns></returns>
        public DataTable GetStorageItem(DateTime startdate, DateTime enddate, string strbelong, string strdis, string gcode, string stroageno, int flag)
        {
            return dal.GetStorageItem(startdate, enddate, strbelong, strdis, gcode, stroageno, flag);
        }
  
        /// <summary>
        /// 2015年6月21日 FIFA
        /// 获取待生产入库列表，从出库单过来
        /// </summary>
        /// <param name="belongcity">归属地</param>
        /// <param name="grphiccity">处理地</param>
        /// <returns></returns>
        public DataTable getProduceWaitInStorageList(string belongcity, string graphiccity)
        {
            return dal.getProduceWaitInStorageList(belongcity, graphiccity);
        }


        
        /// <summary>
        /// 
        /// 维护列表
        /// </summary>
        /// <param name="belongcity">归属地</param>
        /// <param name="grphiccity">处理地</param>
        /// <returns></returns>
        public DataTable getProduceInSList(string belongcity, string graphiccity)
        {
            return dal.getProduceInSList(belongcity, graphiccity);
        }

        /// <summary>
        /// 2015年7月1日 FIFA
        /// 获取待生产入库列表，从出库单过来
        /// </summary>
        /// <param name="belongcity">归属地</param>
        /// <param name="grphiccity">处理地</param>
        /// <returns></returns>
        public DataTable getProduceWaitInStorageListAudit(string belongcity, string graphiccity)
        {
            return dal.getProduceWaitInStorageListAudit(belongcity, graphiccity);
        }

                /// <summary>
        /// 获取某一时间内的库存明细
        /// </summary>
        /// <param name="startdate">开始日期</param>
        /// <param name="enddate">结束日期</param>
        /// <param name="strbelong">归属地</param>
        /// <param name="strdis">物理地</param>
        /// <returns></returns>
        public DataTable StorageItemsQuery(string enddate, string bcity, string gcity)
        {
            return dal.StorageItemsQuery(enddate, bcity, gcity);
        }

                /// <summary>
        /// 根据出生产生的ID取得生产返还单的ID
        /// </summary>
        /// <param name="outid">出库生产单的ID</param>
        /// <returns></returns>
        public Model.InStorage GetRsidByOutid(int outid)
        {

            return dal.GetRsidByOutid(outid);
        }

                /// <summary>
        /// 判断重量是否相等 ,相等则可提交
        /// </summary>
        /// <param name="weight"></param>
        /// <param name="insid"></param>
        /// <param name="weighttype">1是Barcode，2是辅料，3是损耗</param>
        /// <returns></returns>
        public bool GetConfirm(decimal weight, int outid, int insid, int weighttype)
        {

            return dal.GetConfirm(weight, outid, insid, weighttype);
        }


             /// <summary>
        /// 获得返还单录入的Barcode
        /// </summary>
        public DataSet GetBarcodeList(int outid)
        {
            return dal.GetBarcodeList(outid);
        }

        
        /// <summary>
        /// 获得返还单录入的Barcode
        /// <param name="outid">出库单id</param>
        /// <param name="instype">入库单类型 生产领料或者返还</param>
        /// </summary>
        public DataSet GetBarcodeList(int outid, string instype)
        {
            return dal.GetBarcodeList(outid, instype);
        }

              /// <summary>
        /// 取得领料单的总重量
        /// </summary>
        /// <param name="insid"></param>
        /// <param name="nwt"></param>
        /// <returns></returns>
        public decimal GetInsTotal(string insid)
        {
            return dal.GetInsTotal(insid);
        }

                /// <summary>
        /// 取得barcode列表领料单或者返还单
        /// </summary>
        /// <param name="outid"></param>
        /// <param name="type">S领料单 G返还单</param>
        /// <returns></returns>
        public DataTable bindBarcodeList(int outid, string type)
        {

            return dal.bindBarcodeList(outid, type);
        }


        /// <summary>
        /// 
        /// </summary>
        /// <param name="outid"></param>
        /// <returns></returns>
        public List<Model.sc_xh> GetSHList(string outid)
        {
            return dal.GetSHList(outid);
        }

                /// <summary>
        /// 删除领料库存
        /// </summary>
        /// <param name="id"></param>
        /// <returns>0是已经出库 -1 是barcode不存在 1是删除成功 -2是删除barcode失败 -3删除库存失败</returns>
        public int DelBarCodeMaterial(int id)
        {
            return dal.DelBarCodeMaterial(id);
        }

        /// <summary>
        /// 入库单插入或者修改
        /// </summary>
        /// <returns></returns>
        public int Save(Model.InStorage ins)
        {
            return dal.Save(ins);
        }

               /// <summary>
        /// 
        /// </summary>
        /// <param name="outid"></param>
        /// <param name="strtype">W 代表 领料重量+辅料 S代表 入库重量+损耗 </param>
        /// <returns></returns>
        public string GetStrFormulae(int outid, string strtype)
        {
            return dal.GetStrFormulae(outid, strtype);
        }

        
        /// <summary>
        /// 辅料损耗编号
        /// </summary>
        /// <param name="insid">入库id</param>
        /// <param name="leftChar">H为损耗单号，J为辅料单号</param>
        /// <returns></returns>
        public string GetFSNoint(int insid, char leftChar)
        {
            return dal.GetFSNoint(insid, leftChar);
        }

              /// <summary>
        /// 入库审核通过
        /// </summary>
        /// <returns></returns>
        public int SubmitAudio(int insid, string month)
        {
            return dal.SubmitAudio(insid, month);
        }

                /// <summary>
        /// 库存明细(从汇总过来)
        /// </summary>
        /// <param name="startdate">开始日期</param>
        /// <param name="enddate">结束日期</param>
        /// <param name="strbelong">仓库所属城市</param>
        /// <param name="strdis">仓库地理位置</param>
        /// <param name="gcode">物品编码</param>
        /// <param name="stroageno">库位号</param>
        /// <param name="flag">明细类型</param>
        /// <returns></returns>
        public DataSet ProductionItems(DateTime startdate, DateTime enddate, string strbelong, string strdis, string gcode, string stroageno, int flag)
        {
            return dal.ProductionItems(startdate, enddate, strbelong, strdis, gcode, stroageno, flag);
        }

        
        /// <summary>
        /// 判断生产单的重量是否平衡
        /// </summary>
        /// <param name="outid">出库生产的ID</param>
        /// <param name="insid">入库ID</param>
        /// <returns>真为相等 假为不相等</returns>
        public bool GetFinshed(int insid, int outid)
        {
            return dal.GetFinshed(insid, outid);
        }
    }
}
